// Service Worker for PWA functionality
const CACHE_NAME = 'youxi-game-v1';
const urlsToCache = [
  '/',
  '/index.html',
  '/manifest.json',
  '/assets/main_logo.png',
  '/assets/icon.png',
  '/assets/server_icon.png',
  '/assets/server.png',
  '/assets/text_prompt.png',
  '/assets/age_rating.png',
  '/assets/qr_code.png',
  '/assets/视频.mp4'
];

self.addEventListener('install', function(event) {
  event.waitUntil(
    caches.open(CACHE_NAME)
      .then(function(cache) {
        return cache.addAll(urlsToCache);
      })
  );
});

self.addEventListener('fetch', function(event) {
  event.respondWith(
    caches.match(event.request)
      .then(function(response) {
        if (response) {
          return response;
        }
        return fetch(event.request);
      }
    )
  );
});
